﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DelegatesAndEvents
{
    class Test
    {
        public delegate double myDelegate();
        public static void PrintInvocationList(Delegate someDelegate)
        {
            Console.Write("(");
            Delegate[] list = someDelegate.GetInvocationList();
            foreach (Delegate del in list)
            {
                Console.Write(" {0}", del.Method.Name);
            }
            Console.WriteLine(" )");
        }
        static void Main(string[] args)
        {
            
            
            myDelegate delegSequence1 = new myDelegate(SequencesDelegate.CalculateSequence1);
            myDelegate delegSequence2 = new myDelegate(SequencesDelegate.CalculateSequence2);
            myDelegate delegSequence3 = new myDelegate(SequencesDelegate.CalculateSequence3);
            myDelegate combinedDelegate = (myDelegate)Delegate.Combine(delegSequence1, delegSequence2,delegSequence3);
            PrintInvocationList(combinedDelegate);
            Console.WriteLine(combinedDelegate());
        }
    }
}
